home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / NameRegistry.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  12.4 KB  |  363 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        NameRegistry.p
  3.  
  4.      Contains:    NameRegistry Interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1993-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT NameRegistry;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __NAMEREGISTRY__}
  28. {$SETC __NAMEREGISTRY__ := 1}
  29.  
  30. {$I+}
  31. {$SETC NameRegistryIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37.  
  38.  
  39. {$PUSH}
  40. {$ALIGN POWER}
  41. {$LibExport+}
  42.  
  43. {******************************************************************************
  44.  * 
  45.  * Foundation Types
  46.  *
  47.  }
  48. { Value of a property }
  49.  
  50. TYPE
  51.     RegPropertyValue                    = Ptr;
  52. { Length of property value }
  53.     RegPropertyValueSize                = UInt32;
  54. {******************************************************************************
  55.  * 
  56.  * RegEntryID    :    The Global x-Namespace Entry Identifier
  57.  *
  58.  }
  59.     RegEntryIDPtr = ^RegEntryID;
  60.     RegEntryID = RECORD
  61.         contents:                ARRAY [0..3] OF UInt32;
  62.     END;
  63.  
  64. {******************************************************************************
  65.  *
  66.  * Root Entry Name Definitions    (Applies to all Names in the RootNameSpace)
  67.  *
  68.  *    • Names are a colon-separated list of name components.  Name components
  69.  *      may not themselves contain colons.  
  70.  *    • Names are presented as null-terminated ASCII character strings.
  71.  *    • Names follow similar parsing rules to Apple file system absolute
  72.  *      and relative paths.  However the '::' parent directory syntax is
  73.  *      not currently supported.
  74.  }
  75. { Max length of Entry Name }
  76.  
  77. CONST
  78.     kRegCStrMaxEntryNameLength    = 47;
  79.  
  80. { Entry Names are single byte ASCII }
  81.  
  82. TYPE
  83.     RegCStrEntryName                    = CHAR;
  84.     RegCStrEntryNamePtr                    = ^CHAR;
  85. {  length of RegCStrEntryNameBuf =  kRegCStrMaxEntryNameLength+1 }
  86.     RegCStrEntryNameBuf                    = PACKED ARRAY [0..47] OF CHAR;
  87.     RegCStrPathName                        = CHAR;
  88.     RegPathNameSize                        = UInt32;
  89.  
  90. CONST
  91.     kRegPathNameSeparator        = 58;                            {  0x3A  }
  92.     kRegEntryNameTerminator        = $00;                            {  '\0'  }
  93.     kRegPathNameTerminator        = $00;                            {  '\0'  }
  94.  
  95. {******************************************************************************
  96.  *
  97.  * Property Name and ID Definitions
  98.  *    (Applies to all Properties Regardless of NameSpace)
  99.  }
  100.     kRegMaximumPropertyNameLength = 31;                            {  Max length of Property Name  }
  101.     kRegPropertyNameTerminator    = $00;                            {  '\0'  }
  102.  
  103.  
  104. TYPE
  105.     RegPropertyNameBuf                    = PACKED ARRAY [0..31] OF CHAR;
  106.     RegPropertyName                        = CHAR;
  107.     RegPropertyNamePtr                    = ^CHAR;
  108. {******************************************************************************
  109.  *
  110.  * Iteration Operations
  111.  *
  112.  *    These specify direction when traversing the name relationships
  113.  }
  114.     RegIterationOp                        = UInt32;
  115.     RegEntryIterationOp                    = RegIterationOp;
  116.  
  117. CONST
  118.                                                                 {  Absolute locations }
  119.     kRegIterRoot                = $00000002;                    {  "Upward" Relationships     }
  120.     kRegIterParents                = $00000003;                    {  include all  parent(s) of entry  }
  121.                                                                 {  "Downward" Relationships }
  122.     kRegIterChildren            = $00000004;                    {  include all children  }
  123.     kRegIterSubTrees            = $00000005;                    {  include all sub trees of entry  }
  124.     kRegIterDescendants            = $00000005;                    {  include all descendants of entry  }
  125.                                                                 {  "Horizontal" Relationships     }
  126.     kRegIterSibling                = $00000006;                    {  include all siblings  }
  127.                                                                 {  Keep doing the same thing }
  128.     kRegIterContinue            = $00000001;
  129.  
  130. {******************************************************************************
  131.  *
  132.  * Name Entry and Property Modifiers
  133.  *
  134.  *
  135.  *
  136.  * Modifiers describe special characteristics of names
  137.  * and properties.  Modifiers might be supported for
  138.  * some names and not others.
  139.  * 
  140.  * Device Drivers should not rely on functionality
  141.  * specified as a modifier.
  142.  }
  143.  
  144. TYPE
  145.     RegModifiers                        = UInt32;
  146.     RegEntryModifiers                    = RegModifiers;
  147.     RegPropertyModifiers                = RegModifiers;
  148.  
  149. CONST
  150.     kRegNoModifiers                = $00000000;                    {  no entry modifiers in place  }
  151.     kRegUniversalModifierMask    = $0000FFFF;                    {  mods to all entries  }
  152.     kRegNameSpaceModifierMask    = $00FF0000;                    {  mods to all entries within namespace  }
  153.     kRegModifierMask            = $FF000000;                    {  mods to just this entry  }
  154.  
  155. { Universal Property Modifiers }
  156.     kRegPropertyValueIsSavedToNVRAM = $00000020;                {  property is non-volatile (saved in NVRAM)  }
  157.     kRegPropertyValueIsSavedToDisk = $00000040;                    {  property is non-volatile (saved on disk)  }
  158.  
  159. { ///////////////////////
  160. //
  161. // The Registry API
  162. //
  163. /////////////////////// }
  164. { ///////////////////////
  165. //
  166. // Entry Management
  167. //
  168. /////////////////////// }
  169.  
  170. {-------------------------------
  171.  * EntryID handling
  172.  }
  173. {
  174.  * Initialize an EntryID to a known invalid state
  175.  *   note: invalid != uninitialized
  176.  }
  177. FUNCTION RegistryEntryIDInit(VAR id: RegEntryID): OSStatus; C;
  178. {
  179.  * Compare EntryID's for equality or if invalid
  180.  *
  181.  * If a NULL value is given for either id1 or id2, the other id 
  182.  * is compared with an invalid ID.  If both are NULL, the id's 
  183.  * are consided equal (result = true). 
  184.  }
  185. FUNCTION RegistryEntryIDCompare({CONST}VAR id1: RegEntryID; {CONST}VAR id2: RegEntryID): BOOLEAN; C;
  186. {
  187.  * Copy an EntryID
  188.  }
  189. FUNCTION RegistryEntryIDCopy({CONST}VAR src: RegEntryID; VAR dst: RegEntryID): OSStatus; C;
  190. {
  191.  * Free an ID so it can be reused.
  192.  }
  193. FUNCTION RegistryEntryIDDispose(VAR id: RegEntryID): OSStatus; C;
  194. {-------------------------------
  195.  * Adding and removing entries
  196.  *
  197.  * If (parentEntry) is NULL, the name is assumed
  198.  * to be a rooted path. It is rooted to an anonymous, unnamed root.
  199.  }
  200. FUNCTION RegistryCStrEntryCreate({CONST}VAR parentEntry: RegEntryID; {CONST}VAR name: RegCStrPathName; VAR newEntry: RegEntryID): OSStatus; C;
  201. FUNCTION RegistryEntryDelete({CONST}VAR id: RegEntryID): OSStatus; C;
  202. {---------------------------
  203.  * Traversing the namespace
  204.  *
  205.  * To support arbitrary namespace implementations in the future,
  206.  * I have hidden the form that the place pointer takes.  The previous
  207.  * interface exposed the place pointer by specifying it as a
  208.  * RegEntryID.
  209.  *
  210.  * I have also removed any notion of returning the entries
  211.  * in a particular order, because an implementation might
  212.  * return the names in semi-random order.  Many name service
  213.  * implementations will store the names in a hashed lookup
  214.  * table.
  215.  *
  216.  * Writing code to traverse some set of names consists of
  217.  * a call to begin the iteration, the iteration loop, and
  218.  * a call to end the iteration.  The begin call initializes
  219.  * the iteration cookie data structure.  The call to end the 
  220.  * iteration should be called even in the case of error so 
  221.  * that allocated data structures can be freed.
  222.  *
  223.  *    Create(...)
  224.  *    do (
  225.  *        Iterate(...);
  226.  *    ) while (!done);
  227.  *    Dispose(...);
  228.  *
  229.  * This is the basic code structure for callers of the iteration
  230.  * interface.
  231.  }
  232.  
  233.  
  234. TYPE
  235.     RegEntryIter = ^LONGINT;
  236.  * create/dispose the iterator structure
  237.  *   defaults to root with relationship = kRegIterDescendants
  238.  }
  239. FUNCTION RegistryEntryIterateCreate(VAR cookie: RegEntryIter): OSStatus; C;
  240. FUNCTION RegistryEntryIterateDispose(VAR cookie: RegEntryIter): OSStatus; C;
  241.  * set Entry Iterator to specified entry
  242.  }
  243. FUNCTION RegistryEntryIterateSet(VAR cookie: RegEntryIter; {CONST}VAR startEntryID: RegEntryID): OSStatus; C;
  244. {
  245.  * Return each value of the iteration
  246.  *
  247.  * return entries related to the current entry
  248.  * with the specified relationship
  249.  }
  250. FUNCTION RegistryEntryIterate(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN): OSStatus; C;
  251. {
  252.  * return entries with the specified property
  253.  *
  254.  * A NULL RegPropertyValue pointer will return an
  255.  * entry with the property containing any value.
  256.  }
  257. FUNCTION RegistryEntrySearch(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  258. {--------------------------------
  259.  * Find a name in the namespace
  260.  *
  261.  * This is the fast lookup mechanism.
  262.  * NOTE:  A reverse lookup mechanism
  263.  *      has not been provided because
  264.  *        some name services may not
  265.  *        provide a fast, general reverse
  266.  *        lookup.
  267.  }
  268. FUNCTION RegistryCStrEntryLookup({CONST}VAR searchPointID: RegEntryID; {CONST}VAR pathName: RegCStrPathName; VAR foundEntry: RegEntryID): OSStatus; C;
  269. {---------------------------------------------
  270.  * Convert an entry to a rooted name string
  271.  *
  272.  * A utility routine to turn an Entry ID
  273.  * back into a name string.
  274.  }
  275. FUNCTION RegistryEntryToPathSize({CONST}VAR entryID: RegEntryID; VAR pathSize: RegPathNameSize): OSStatus; C;
  276. FUNCTION RegistryCStrEntryToPath({CONST}VAR entryID: RegEntryID; VAR pathName: RegCStrPathName; pathSize: RegPathNameSize): OSStatus; C;
  277. {
  278.  * Parse a path name.
  279.  *
  280.  * Retrieve the last component of the path, and
  281.  * return a spec for the parent.
  282.  }
  283. FUNCTION RegistryCStrEntryToName({CONST}VAR entryID: RegEntryID; VAR parentEntry: RegEntryID; VAR nameComponent: RegCStrEntryName; VAR done: BOOLEAN): OSStatus; C;
  284. { //////////////////////////////////////////////////////
  285. //
  286. // Property Management
  287. //
  288. ////////////////////////////////////////////////////// }
  289. {-------------------------------
  290.  * Adding and removing properties
  291.  }
  292. FUNCTION RegistryPropertyCreate({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  293. FUNCTION RegistryPropertyDelete({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName): OSStatus; C;
  294. {---------------------------
  295.  * Traversing the Properties of a name
  296.  *
  297.  }
  298.  
  299. TYPE
  300.     RegPropertyIter = ^LONGINT;
  301. FUNCTION RegistryPropertyIterateCreate({CONST}VAR entry: RegEntryID; VAR cookie: RegPropertyIter): OSStatus; C;
  302. FUNCTION RegistryPropertyIterateDispose(VAR cookie: RegPropertyIter): OSStatus; C;
  303. FUNCTION RegistryPropertyIterate(VAR cookie: RegPropertyIter; VAR foundProperty: RegPropertyName; VAR done: BOOLEAN): OSStatus; C;
  304. {
  305.  * Get the value of the specified property for the specified entry.
  306.  *
  307.  }
  308. FUNCTION RegistryPropertyGetSize({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; VAR propertySize: RegPropertyValueSize): OSStatus; C;
  309. {
  310.  * (*propertySize) is the maximum size of the value returned in the buffer
  311.  * pointed to by (propertyValue).  Upon return, (*propertySize) is the size of the
  312.  * value returned.
  313.  }
  314. FUNCTION RegistryPropertyGet({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; VAR propertySize: RegPropertyValueSize): OSStatus; C;
  315. FUNCTION RegistryPropertySet({CONST}VAR entryID: RegEntryID; {CONST}VAR propertyName: RegPropertyName; propertyValue: UNIV Ptr; propertySize: RegPropertyValueSize): OSStatus; C;
  316. { //////////////////////////////////////////////////////
  317. //
  318. // Modibute (err, I mean Modifier) Management
  319. //
  320. ////////////////////////////////////////////////////// }
  321. {
  322.  * Modifiers describe special characteristics of names
  323.  * and properties.  Modifiers might be supported for
  324.  * some names and not others.
  325.  * 
  326.  * Device Drivers should not rely on functionality
  327.  * specified as a modifier.  These interfaces
  328.  * are for use in writing Experts.
  329.  }
  330. {
  331.  * Get and Set operators for entry modifiers
  332.  }
  333. FUNCTION RegistryEntryGetMod({CONST}VAR entry: RegEntryID; VAR modifiers: RegEntryModifiers): OSStatus; C;
  334. FUNCTION RegistryEntrySetMod({CONST}VAR entry: RegEntryID; modifiers: RegEntryModifiers): OSStatus; C;
  335. {
  336.  * Get and Set operators for property modifiers
  337.  }
  338. FUNCTION RegistryPropertyGetMod({CONST}VAR entry: RegEntryID; {CONST}VAR name: RegPropertyName; VAR modifiers: RegPropertyModifiers): OSStatus; C;
  339. FUNCTION RegistryPropertySetMod({CONST}VAR entry: RegEntryID; {CONST}VAR name: RegPropertyName; modifiers: RegPropertyModifiers): OSStatus; C;
  340. {
  341.  * Iterator operator for entry modifier search
  342.  }
  343. FUNCTION RegistryEntryMod(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; matchingModifiers: RegEntryModifiers): OSStatus; C;
  344. {
  345.  * Iterator operator for entries with matching 
  346.  * property modifiers
  347.  }
  348. FUNCTION RegistryEntryPropertyMod(VAR cookie: RegEntryIter; relationship: RegEntryIterationOp; VAR foundEntry: RegEntryID; VAR done: BOOLEAN; matchingModifiers: RegPropertyModifiers): OSStatus; C;
  349.  
  350.  
  351. {$ALIGN RESET}
  352. {$POP}
  353.  
  354. {$SETC UsingIncludes := NameRegistryIncludes}
  355.  
  356. {$ENDC} {__NAMEREGISTRY__}
  357.  
  358. {$IFC NOT UsingIncludes}
  359.  END.
  360. {$ENDC}
  361.